// pages/function/size.js
var util = require('../../utils/util');
var that;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentTab:0,
    inputT:'',
    text: '',
    icurl:'',
    date:'',
    time:''
  },

  bindDateChange: function (e) {
    var date = e.detail.value;
    if (!date) return;
    that.setData({ date: date })
  },
  bindTimeChange: function (e) {
    var time = e.detail.value;
    if (!time) return;
    that.setData({ time: time })
  },
  saveH:function(){
    var location = (that.data.currentTab + 2);
    util.sendRequest('WXAddYW', { type: location, value: that.data.inputT, time: (that.data.date + ' ' + that.data.time) },
      function (resp) {
        if (resp.code == 0) {
          wx.redirectTo({
            url: '/pages/personal/percenter',
          })
        }
      }, '保存中...', function () {

      });
  },
  inputText:function(e){
    that.setData({ inputT: e.detail.value });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
    that.setData({ time: util.formatDate(new Date(), 'hh:ss'), date: util.formatDate(new Date(), 'yyyy-MM-dd') })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
      return util.getShareMsg();
  }
  ,  /*** 滑动切换tab***/
  bindChange: function (e) {
    var that = this;
    that.setData({ currentTab: e.detail.current });
  },
  swichNav:function(e){
    var that = this;

   if (this.data.currentTab === e.target.dataset.current) {
      return false;
    }
    else {
      that.setData({
        currentTab:e.target.dataset.current,
      })
    }
    
  }
})